package lex.mxbeans.ui;

import javax.swing.JDesktopPane;

import lex.mxbeans.utils.MXBeanInfo;

public class MainContentPane extends JDesktopPane {
	private MXBeansBrowser mxbeansBrowser = null;

	public MainContentPane() {
		this.initialize();
	}

	public void showMXBean(MXBeanInfo bean) {
		MXBeanViewer viewer = new MXBeanViewer();
		viewer.setMXBean(bean);
		viewer.setSize(450, 450);
		viewer.setLocation(32, 32);
		this.add(viewer);
		viewer.setVisible(true);
	}

	private MXBeansBrowser getMxbeansBrowser() {
		if (null == mxbeansBrowser) {
			mxbeansBrowser = new MXBeansBrowser();
			mxbeansBrowser.setSize(220, 300);
			mxbeansBrowser.setLocation(0, 0);
			mxbeansBrowser.putClientProperty("JInternalFrame.isPalette", Boolean.TRUE);
			mxbeansBrowser.setVisible(true);
		}
		return mxbeansBrowser;
	}

	private void initialize() {
		this.add(this.getMxbeansBrowser());
		// ===================================
		this.setSelectedFrame(this.mxbeansBrowser);
	}
}
